<?php

namespace App\Http\Controllers\Blog;

use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Http\Responses\Response;

class CategoryController extends Controller
{
    /**
     * list all categories that's status is show
     */
    public function list(){
        // 查询所有的父分类
;
        $categories = Category::with("children")
            ->where('cate_status', '=', 0)
            ->whereNull('cate_parent')
            ->orderByDesc("cate_weight")
            ->get();

        return  Response::resource_success($categories);
    }
}
